import 'dart:convert';

import 'ni_base_model.dart';
import 'ni_geopoint_model.dart';

///marker 数据信息
class NIMarker implements NIModel {
  String? description;
  String id;
  NIGeoPoint geoPoint;

  NIMarker({required this.geoPoint, this.description = "", required this.id});

  factory NIMarker.fromJson(String json) {
    Map<String, dynamic> map = jsonDecode(json);
    return NIMarker.fromMap(map);
  }

  factory NIMarker.fromMap(Map<String, dynamic> map) {
    return NIMarker(
        geoPoint: NIGeoPoint.fromMap(map['geoPoint']),
        id: map['id'],
        description: map['description']);
  }

  @override
  String toJson() {
    return '{"geoPoint": ${geoPoint.toJson()},"description": ${description == null ? "" : description!}, "id": $id}';
  }

  @override
  Map<String, dynamic> toMap() {
    return {
      "geoPoint": geoPoint.toMap(),
      "description": description == null ? "" : description!,
      "id": id
    };
  }
}
